/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.agreement.service.yearcarsalepurchaseagreement;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.agreement.dao.yearcarsalepurchaseagreement.YearCarSalePurchaseAgreementDao;
import com.jeesite.modules.agreement.entity.yearcarsalepurchaseagreement.YearCarSalePurchaseAgreement;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 年度汽车买卖协议Service
 * @author Kilo
 * @version 2021-03-04
 */
@Service
@Transactional(readOnly=true)
public class YearCarSalePurchaseAgreementService extends CrudService<YearCarSalePurchaseAgreementDao, YearCarSalePurchaseAgreement> {
	
	/**
	 * 获取单条数据
	 * @param yearCarSalePurchaseAgreement
	 * @return
	 */
	@Override
	public YearCarSalePurchaseAgreement get(YearCarSalePurchaseAgreement yearCarSalePurchaseAgreement) {
		return super.get(yearCarSalePurchaseAgreement);
	}
	
	/**
	 * 查询分页数据
	 * @param yearCarSalePurchaseAgreement 查询条件
	 * @param yearCarSalePurchaseAgreement.page 分页对象
	 * @return
	 */
	@Override
	public Page<YearCarSalePurchaseAgreement> findPage(YearCarSalePurchaseAgreement yearCarSalePurchaseAgreement) {
		return super.findPage(yearCarSalePurchaseAgreement);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param yearCarSalePurchaseAgreement
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(YearCarSalePurchaseAgreement yearCarSalePurchaseAgreement) {
		if(yearCarSalePurchaseAgreement.getIsNewRecord()){
			yearCarSalePurchaseAgreement.setCreateBy(UserUtils.getUser().getLoginCode());
			yearCarSalePurchaseAgreement.setUpdateBy(UserUtils.getUser().getLoginCode());
		}else{
			yearCarSalePurchaseAgreement.setUpdateBy(UserUtils.getUser().getLoginCode());
		}
		super.save(yearCarSalePurchaseAgreement);
		// 保存上传附件
		FileUploadUtils.saveFileUpload(yearCarSalePurchaseAgreement.getId(), "yearCarSalePurchaseAgreement_file");
	}
	
	/**
	 * 更新状态
	 * @param yearCarSalePurchaseAgreement
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(YearCarSalePurchaseAgreement yearCarSalePurchaseAgreement) {
		super.updateStatus(yearCarSalePurchaseAgreement);
	}
	
	/**
	 * 删除数据
	 * @param yearCarSalePurchaseAgreement
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(YearCarSalePurchaseAgreement yearCarSalePurchaseAgreement) {
		super.delete(yearCarSalePurchaseAgreement);
	}
	
}